use std::str::Utf8Error;

#[derive(Debug, thiserror::Error)]
pub enum WebSocketReceiveError {
    #[error("Faile to parse frame: {0}")]
    Parse(#[from] WebSocketParseError),

    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Connection closed unexpectedly")]
    ConnectionClosed,
}

#[derive(Debug, thiserror::Error)]
pub enum WebSocketSendError {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),
}

#[derive(Debug, thiserror::Error)]
pub enum WebSocketParseError {
    #[error("Invalid utf8 string: {0}")]
    InvalidUtf8String(#[from] Utf8Error),

    #[error("Unmatch opcode: {0}")]
    OpCodeUnmatch(String),
}